<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html style="overflow: hidden;height:100%;">
	<head>
		<title>${lotter.name }</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<style type="text/css">
			.qiu{margin-right:3px;color:white;width:22px;height:22px;line-height:22px;font-size:12px;display:inline-block;background: #E63131;}
			.btn2{background: none;border: 0;color: #009ac3;font-size: 15px;padding:3px 0px; border-radius:5px;}
			/**.btn2{background: none;border: 0;color: #fff;font-size: 15px;padding:3px 5px;border-radius:5px;}*/
			.btn3{border:0px;border-radius:50px;padding:2px;width:26px;height:26px;line-height:20px;color: white;}
			.qiu0{background: #D8D21C!important;}
			.qiu1{background: #D8D21C!important;}
			.qiu2{background: #3273F9!important;}
			.qiu3{background: #515567!important;}
			.qiu4{background: #E6962D!important;}
			.qiu5{background: #0EC2C4!important;}
			.qiu6{background: #2D35D0!important;}
			.qiu7{background: #AEAFC5!important;}
			.qiu8{background: #E63131!important;}
			.qiu9{background: #7C1F1F!important;}
			.qiu10{background: #2DCC21!important;}
			/* .table>tbody>tr>td {
			    display: -webkit-box;
			} */
			.hb{background: #F02828;}
			.lbo{background: #336DCC;}
			.lvbo{background: #09B832;}
			.table1{margin-top: 5px;}
			.table1 tr td{height: 30px;padding:0 5px;font-size: 14px;}
			.ctr{color: ;font-weight: bold;}
			.xiazhu .title{background:#EFEFEF;padding: 8px;border-bottom: 1px solid silver;}
			.xiazhu .col-xs-6,.xiazhu .myfl{border: 1px solid #ECECEC ;padding: 5px;padding: 13px 0px;}
			.xiazhu .col-xs-6 button{margin-right: 20px;}
			.xiazhu .row{margin: 0px;}
			.xiazhu input{display:none;border:1px solid red;}
			.xiazhu span{color: gray;display: inline-block;min-width: 40px;font-size: 12px;}
			.xiazhu .act{background: url("/img/actbg.png");background-size: 20px 20px;background-repeat: no-repeat;}
			/* .xiazhu .act *{color: white;} */
			
			.zdsd *{font-size: 14px;}
			.hemei input{text-align: center;}
			
			*{font-size: 14px;}
			.wf a{background: #EFEFEF;color:black; width: 98%;text-align: center;padding:5px;display: block; display: -moz-box;border: 1px solid white;font-size: 12px;cursor: pointer;}
			.wf .acti{background: #02AECB;color: white;}
			.wfdiv:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
            .clearfix:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
            .modal-dialog {
            	margin:10px 0!important;
            }
			.nav a{color:white;}
			#myModal .modal-dialog, #betSuccessModal .modal-dialog {margin: 0 auto!important;padding:10px;}
			.item .important{color:red;font-weight :bold;}
			.item .nickname{color:#099afe}
			.item,.item *{font-size:12px;}
			.item{padding-left:30px;}
			.nav>li>span {
				color:white;
				position: relative;
			    display: block;
			    padding: 10px 15px;
			}
			.wf {width:100px;overflow:auto;max-height:100%;-webkit-overflow-scrolling: touch;}
			.green{border-radius:10px; border:1px solid silver ;box-shadow: 2px 3px 1px silver;padding:10px;padding-left:10px; ;line-height:30px;margin-bottom: 20px;text-align: left;}
			.green{border-top:5px solid green;}
			
			.span-item-circle {
				display: inline-flex;
			    background: red;
			    margin: 1px;
			    border-radius: 50%;
			    color: white;
				font-size: 0.33rem;
			    width: 0.46rem;
			    height: 0.46rem;
			    justify-content:center;
			    align-items:center;
			    max-width:26px;
			    max-height:26px;
			}
			.clearfix:after {
				content:"";
				display:block;
				clear:both;
			}		
			.modal-footer {
				padding:6px;
				text-align: center;
			}	
			.modal-footer > button {
				width:80%;
			} 
			.ul-c-betSuccessItem {
			    padding: 10px;
			    padding-left: 30px;
			    line-height: 30px;
			    margin-bottom: 20px;
			    text-align: left;
			    overflow: auto;				
			}
			#betSuccessModal .modal-body {
				max-height:80vh;
			}
			#checkboxhm, #checkboxgd {
				width:20px;
				height:20px;
			}
			.zdsd.set {
				max-width:360px;
				left:50%!important;
				transform:translateX(-50%);
				margin:0!important;
			}
			.col-sm-4, .col-xs-12 {
				padding-left:0;
				padding-right:0;
			}
			.clearfix:after {
				content:"";
				display:block;
				clear:both;
			}
			#djs .yuan, #djs .fakejiahao {
				font-weight:normal!important;
			}
			.nav>li>span:hover {
				background-color:#eee;
			}
			.xiazhu > div > div, #id-ul-xiaLaMenu > li > a, #id-ul-xiaLaMenu > li > span {
				cursor: pointer;
			}
			.xiazhu > div > .title {
				cursor: default;
			}
			.span-c-gendanWrapper, .span-c-hemaiWrapper {
				display:none;
			}
			.span-c-gendanWrapper.active, .span-c-hemaiWrapper.active {
				display:inline-flex;
			}
			.span-c-gendanWrapper, .span-c-hemaiWrapper {
				align-items:center;
			}
			#fenpan {
				z-index:20;
			}
			.nav>li>a:focus, .nav>li>a:hover, .nav>li>span:focus, .nav>li>span:hover {
				background-color:rgb(23,162,244)!important;
			}
			.col-xs-6:after, .col-xs-12, .wfdiv {
				content:"";
				display:block;
				clear:both;
			}
			#kuaisuxuanze button{width: 17%;margin:0 1%;}
		</style>
		
	<body style="height: 100%;">
	 <div id="loading" class="kd-loading">
	<div class="kd-spinner">
		<span class="bounce b1"></span>
		<span class="bounce b2"></span>
		<span class="bounce b3"></span>
	</div>
	<p>&nbsp;</p>
	<p>&nbsp;</p>
	<p>请稍等，努力加载中...</p>
</div>
 
		<div class="" style="display:none; padding:0;">
			<span id="id" class="hidden">${lotter.id }</span>
			<span id="cplay1" class="hidden">${keyChinese }</span>
			<span id="cname1" class="hidden">${lotter.name }</span>
			<span id="orderid" class="hidden"></span>
			<span id="cname" class="hidden">${lotter.cname }</span>
			<span class="timespace hidden">${lotter.timespace }</span>
			<span id="lasttime" class="lasttime hidden">${lotter.lottertime }</span>
			<span id="cplay" class="hidden">${key}</span>
			<div class="" style="background: url('/img/actbg.png');"></div>
		</div>
			
		<div style="display:flex;flex-direction:column;height:100%;visibility: hidden;" class="clearfix" id="sdfsddf" > 
			<div id="id-div-headerNav" class="col-xs-12 col-sm-4 col-sm-offset-4" style="display:flex;justify-content:space-between;background-color:#059BF3;align-items:center;padding:0 10px;height:50px;position:fixed;z-index:4;">
				<a href="/gc.do" class="glyphicon glyphicon-chevron-left" style="color: white;margin-top:-4px;"></a>
				<div style="position:absolute;transform:translateX(-50%) translateY(-50%);left:50%;top:50%;">
					<div class='font12	' style="color:yellow;">当期下注总额：<span id="span-i-xiazhuzonge"></span></div>
					<div style="color: white;font-weight: bold;font-size: 16px;text-align: center;" class="CZname" >${lotter.name }</div>
				</div>
				
				<div style="display:flex;align-items:center;position:absolute;top:50%;transform:translateY(-50%);right:10px;"class="user">
					<div style="color: white;display:flex;flex-direction:column;align-items:flex-end;margin-right:10px;line-height:14px;">
						<span style="font-size: 12px;">余额</span>
						<span style="font-size: 12px;" id="balance"></span>
					</div>	
					<i class="glyphicon glyphicon-menu-hamburger" style="font-size:20px;color:white;cursor: pointer;"></i>
				</div>	
	
				<ul id="id-ul-xiaLaMenu" class="nav hidden" style="position: absolute;right:0px;top:100%;width:100px;text-align: center;z-index:100;background: rgb(23,162,244) ;border-radius:0; ">
					<li><a href="/order/myOrderPage.do">下注记录</a></li>
					<li><a id="a-i-lotterRecord">开奖记录</a></li>
					<li><span id="a-i-zoushitu">走势图</span>
					<span id="cname" class="hidden">${lotter.cname}</span>
					<li><a onclick="help('${lotter.cname}','${lotter.name }')">购彩助手</a></li>
					<li><a href="/wd.do">我的地盘</a></li>
					<li><a href="/exit.do">退出登录</a></li>
				</ul>	
			</div>
			<div style="background-color:white;line-height:25px;padding:0 6px;top:50px;position: fixed;z-index:3;"class="class-div-qiuGroups col-xs-12 col-sm-4 col-sm-offset-4">
				<p style="margin-bottom:0px;display:flex;align-items:center;flex-wrap:wrap;"><span style="display:inline-block;min-width:64px;white-space: nowrap;font-size: 13px;"><span style="font-size: 13px;" class="period">${lotter.period }</span><span class="">期：</span></span><span class="lotternumber" style="display:flex;flex-grow:1;white-space: nowrap;">${lotter.lotternumber }</span></p>
				<p style="padding-top:4px;margin-bottom:0px;"><span style="display:inline-block;min-width:64px;"><span style="font-size: 13px;" class="xiaqi">${lotter.period+1 }</span><span class="">期： </span></span><span id="djs" style="font-size: 13px;font-weight: bold;"></span></p>
				<div title="1463" class="kd-marquee kd-container" style="max-width:100%;overflow:hidden;">
					<div id="test1" class="inner" >
						<nobr style="display:block;">
						</nobr>
					</div>
				</div>				
			</div>
			<div style="display:flex;margin-bottom:54px;" class="class-div-contentDiv col-xs-12 col-sm-4 col-sm-offset-4">	
					${str }
				<div class="clearfix xiazhu" style="overflow:auto;-webkit-overflow-scrolling: touch;position:relative;z-index:2;text-align:center;">
					<!-- 下注区 -->
						${xiazhuqu }
					<!-- 下注区 -->
				</div>	
			</div>
			<div style="position: fixed;bottom:0;z-index:3;" id="div-i-footer-hemai" class="col-xs-12 col-sm-4 col-sm-offset-4">
				<div style="border-top:2px solid silver;padding:5px 10px;height: 54px;background: white;" id="foot" class="">
					<div class="" style="padding: 0; float: left;">
						<div> <span style="margin-right:12px;">单注金额</span><input maxlength="10" id="dzje" style="width:80px;border-radius: 1px;border: 1px solid silver ;font-size:20px;" type="number" value="2" /></div>
						<div class="font10">已选 <span id="zhushu" class="font10" style="min-width:14px;display:inline-block;text-align:center;">0</span>注，共计<span id="gongji" style="min-width:14px;display:inline-block;text-align:center;" class="font10">0</span>元</div> 
					</div>
					<div class="" style="padding-top:4px;align-items:center;float: right;">
						<div class="">
							<a onclick="clear1()" class="btn btn-sm" style="background: #eb6066;color:white;border:1px solid #eb6066;padding: 5px 20px;font-size:14px;">清空</a>
							<a id="queding" onclick="comit()" class="btn btn-sm queren" style="border:1px solid black;padding: 5px 20px;font-size:14px;">确定</a>
						</div>
					</div>
				</div>		
			</div>
			<div  class="col-xs-12 col-sm-4 col-sm-offset-4 hidden" id="kuaisuxuanze" style="position: fixed;bottom: 0;background: white;height: 40px;z-index:10;border-top:1px solid silver;padding-top:2px;">
				<button class="btn btn-default">${buy1}</button>
				<button class="btn btn-default">${buy2}</button>
				<button class="btn btn-default">${buy3}</button>
				<button class="btn btn-default">${buy4}</button>
				<button class="btn btn-default">${buy5}</button>
			</div>
		</div>
	<div class="zdsd hidden" style='position: absolute;top:0;left:0;width: 100%;height: 100%;z-index: 60;background:rgba(0,0,0,0.5) ;'>
	</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:90vw;max-width:600px;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel" style="text-align: center;letter-spacing: 3px;">★${lotter.name }★</h4>
            </div>
            <div class="modal-body" style="height:65vh;overflow:auto;">
 				
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关　闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->	
<!-- 模态框（Modal） -->
<div class="modal fade" id="betSuccessModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog" style="max-height:60vh;">
        <div class="modal-content" style="height:100%;">
            <div class="modal-header">
                <h4 style="text-align: center;font-weight:bold;" class="modal-title" id="myModalLabel">下注成功！</h4>
            </div>
            <div class="modal-body" style="overflow:auto;max-height:60vh;">
                <table class="table table-striped table-bordered table-hover" style="overflow: auto;">
            		<tbody class="ul-c-betSuccessItem">
            			
            		</tbody>
            	</table>
<!--             	<ul class="ul-c-betSuccessItem">
            	</ul> -->
            </div>
            <div class="modal-footer">
                <button style="" type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
	
<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
	</div>
</div>		
<div id='fenpan' class='hidden col-xs-12 col-sm-4 col-sm-offset-4' style='position: fixed;bottom:0px;background:rgba(200,200,200,0.8);height:54px;line-height:54px;font-size:30px;text-align:center;color:white;'>已封盘</div>	
</div>
	</body>
	<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script type="text/javascript" src="/js/lotterHelper.js"></script>
	<script type="text/javascript">
	  document.onreadystatechange = function(){ 
		　　 if(document.readyState == "complete"){ 　　//当页面加载状态为完全结束时进入 
		    　 //你要做的操作。
			 $("#sdfsddf")[0].style.visibility="visible" 
			 $(".kd-loading").hide()
		   　 }
		}  
	DaoJiShiTask()
	var state = false
	var daojishi = 0
	function DaoJiShiTask(){
		$("#fenpan").removeClass("hidden")
		var timer = setInterval(DaoJiShi, 1000);
		//倒计时时间
		var a = 4
		 function DaoJiShi(){
			 daojishi--;
		 	var h = parseInt(daojishi/ 60 / 60 % 60) //时
		    var m = parseInt(daojishi/ 60 % 60)  //分
		 	var s = parseInt(daojishi% 60)  //秒
		 	if(h <= 0 && m <= 0 && s <= 0){
			 	$("#djs").text("00:00:00")
		 		state = true
			}else{
					if(h < 10){
						h = "0"+h
					}
					if(m < 10){
						m = "0"+m
					}
					if(s < 10){
						s = "0"+s
					}
					$("#djs").text(h+":"+m+":"+s)
			}
		 	if(h <= 0 && m <= 0 && s <= 30){
		 		$("#fenpan").removeClass("hidden")
		 	}else{
		 		$("#fenpan").addClass("hidden")
		 	}
		 	if(state){
		 		a++
		 		if(a >= 4){
		 			a = 0
			 		$.ajax({
						url: "/findNextNextPeriod.do",
						type: "post",
						data: {
							"cname":$("#cname").text(),
							"type":1
						},
						success: function(data) {
							var fnextPeriod = data.data.nextperiod
							var nextPeriod = $(".xiaqi").text()//页面期号
							if(fnextPeriod >= nextPeriod){
								$(".xiaqi").text(fnextPeriod)//下期期号
								$(".period").text(data.data.period)//写入期号
								var curTime=new Date(data.message).getTime(); //当前系统毫秒时间
								var nextTime=new Date(data.data.nextStopOrderTimeEpoch).getTime();//下棋开奖时间
								daojishi =(nextTime-curTime)/1000;  //倒计时时间
								console.log(daojishi)
							}
							console.log($(".period").text(),data.data.period)
							if($(".period").text() == data.data.period){
								var haoma="";
								var lotterNumber =  data.data.lotternumber
								if(lotterNumber==null){
									lotterNumber = ""
								}
								lotterNumber1=lotterNumber.split(",");
								if(lotterNumber1.length > 1){
									$(".lotternumber").text(lotterNumber)
									 qiu()
									state = false;
								}else{
									$(".lotternumber").html("<span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>正</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>在</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>开</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>奖</span>")
								}
							}
						}
					})
		 		}
		 	}
		 }
	}
	
	$("#kuaisuxuanze button").on("click",function(){
		$("#dzje").val($(this).text())
		gongji();
	})
	$("#dzje").on("focus",function(){
		$("#div-i-footer-hemai").css("bottom","40px");
		$("#kuaisuxuanze").removeClass("hidden")
	})
	$("*").not("#dzje").on("click",function(){
		$("#div-i-footer-hemai").css("bottom","0");
		$("#kuaisuxuanze").addClass("hidden")
	})
var ZONGZHUSHU = 0;
	
	$("#dzje").on("blur",function(){
		gongji();
	})
	function gongji(){
		ZONGZHUSHU=Number($("#dzje").val().trim())*Number($("#zhushu").text());
		$("#gongji").text(ZONGZHUSHU);
	}
	
	
var ALL_TIME	
var TIME_EVENT_ID
var IS_TIME_CURRENT
var SPECIAL_CAIZHONG = ["bjpk10", "2fpk10"]
var NOT_STOP = ["2fpk10", "2fssc", "xysm", "3fk3"]
var ISFIRSTLOTTER_flag = true
var MONEY_FROM_SERVER = ""
var COUNT_FROM_SERVER = 0
var isNeedFengPan = true
var COLOR_OBJECT = {
		"1": "qiu1",
		"2": "qiu2",
		"3": "qiu3",
		"4": "qiu4",
		"5": "qiu5",
		"6": "qiu6",
		"7": "qiu7",
		"8": "qiu8",
		"9": "qiu9",
		"10":  "qiu10"
}
// 开始开奖
if ($("#cname").text() === "xg6hc") {
	getXiangGangLiuHeCaiData()
	autoUpdateXiangGangLiuHeCai()
} 
else if($("#cname").text() === "fc3d" || $("#cname").text() === "pl3"){
	getDayOneLotterFunction($("#cname").text())
} 
else {
}


function getDayOneLotterFunction(cname) {
	ajax({
		url:'/lotter/getnewdata.do',
		type:'post',
		data:{key: cname},
		success:function(data){
			var json=eval('('+data+')')
			var timeSpace = json.data.timespace
			var qihao = json.data.period
			if (qihao === $(".xiaqi").text()) {
				$(".period").text($(".xiaqi").text())
				$(".xiaqi").text(Number($(".xiaqi").text()) +1)
				$(".lotternumber").text(json.data.lotternumber)
				qiu()
			}
			/* var chaValue = Math.floor(new Date(transDateLetter(json.data.nextStopOrderTimeEpoch)).getTime() / 1000) - Math.floor(new Date(transDateLetter(json.message)).getTime() / 1000)
			dayOneLotterDaoJiShi(chaValue, cname) */
		}
	})				
}

var XIANGGANGLIUHECAI_INTERVAL_ID
var QING_QIU_FLAG = true

function xianggangLiuHeCaiDaoJiShi(chaValue) {
	var s = chaValue
	if (s == 0 || s <= 0) {
	      if (isNeedFengPan) {
	          $("#fenpan").removeClass("hidden")
	        }
		$("#djs").html("<span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>正</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>在</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>开</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>奖</span>")
		QING_QIU_FLAG = false
		getXiangGangLiuHeCaiData()
		return			
	} else {
		QING_QIU_FLAG = true
		showTimeInfo(s)
	}
	XIANGGANGLIUHECAI_INTERVAL_ID = setInterval(function() {
		s -= 1
		if (s == 0 || s <= 0) {
		      if (isNeedFengPan) {
		          $("#fenpan").removeClass("hidden")
		        }
			$("#djs").html("<span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>正</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>在</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>开</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>奖</span>")
			clearInterval(XIANGGANGLIUHECAI_INTERVAL_ID)
			QING_QIU_FLAG = false
			getXiangGangLiuHeCaiData()
			return			
		}
		QING_QIU_FLAG = true
		showTimeInfo(s)
		if (s <= 30 || $("#djs").text == "正在开奖") {
		      if (isNeedFengPan) {
		          $("#fenpan").removeClass("hidden")
		        }
		}
		else {
			$("#fenpan").addClass("hidden")
		}
	},1000)
}

function getNextXiangGangLiuHeCai(stateValue) {
	ajax({
		url: '/lotter/xglhc.do',
		type:'post',
		data: {
			cname: "xg6hc",
			xg6hc: stateValue,
			},
		success:function(data){
			var newData = JSON.parse(data)
			var nextObj = newData.data
			$(".xiaqi").text(nextObj.period)
			var nowTime = transDateLetter(newData.message)
			var nextTime = transDateLetter(nextObj.nextStopOrderTimeEpoch)			
			var chazhiValue = Math.floor(new Date(nextTime).getTime() / 1000) - Math.floor(new Date(nowTime).getTime() / 1000)			
 			// 一直没有派奖，现在正在开奖
			if (nextObj.touzhuzt === null && chazhiValue <= 0) {
				$("#djs").html("<span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>正</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>在</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>开</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>奖</span>")
      if (isNeedFengPan) {
        $("#fenpan").removeClass("hidden")
      }
				QING_QIU_FLAG = false
				setTimeout(function() {
					getXiangGangLiuHeCaiData()
				}, 1000)
			}
			// 一直没有派奖，显示倒计时
			else if(nextObj.touzhuzt === null && chazhiValue > 0) {
				xianggangLiuHeCaiDaoJiShi(chazhiValue)
			}
			// nextObj.touzhuzt != null, 直接显示
			else {
			      if (isNeedFengPan) {
			          $("#fenpan").removeClass("hidden")
			        }
				$("#djs").html(nextObj.lotternumber)
				xianggangLiuHeCaiLotter("#djs")
				QING_QIU_FLAG = false
				setTimeout(function() {
					getXiangGangLiuHeCaiData()
				}, 1000)
			}			
		}
	})	
}

function getXiangGangLiuHeCaiData() {
	ajax({
		url:'/lotter/xglhc.do',
		type:'post',
		data: {
			cname: "xg6hc",
			xg6hc: "",
			},
		success:function(data){
			var newData = JSON.parse(data)
			var lastObj = newData.data
			$(".period").text(lastObj.period)
			$(".lotternumber").text(lastObj.lotternumber)
			xianggangLiuHeCaiLotter(".lotternumber")
			getNextXiangGangLiuHeCai(lastObj.xg6hcstate + 1)
		}
	})
}

function autoUpdateXiangGangLiuHeCai() {
	setInterval(function() {
		if (QING_QIU_FLAG) {
			window.clearInterval(XIANGGANGLIUHECAI_INTERVAL_ID)
			getXiangGangLiuHeCaiData()	
		}
	}, 5000)
}

	function cancel(){$(".zdsd").addClass("hidden");$("#checkboxhm").removeAttr("checked");}
		function clear1() {
			ZHUSHU = 0
			$(".act").removeClass("act");
			$(".wfdiv input").val("");
			$("#zhushu").text("0")
			$("#gongji").text("0");
		}
		function submit(){
			$(".zdsd").addClass("hidden");
		}
		
		
		var confirmXiaZhu = function(rebate, testState, slv) {
			var odd = 1
			if ($("#checkboxhm").is(':checked')) {
				odd = 2
			} 
			else if ($("#checkboxgd").is(':checked')) {
				odd = 3
			}
		
			var ajaxData = {
				url: '/order/awards.do',
				type: "post",
				data: {
					lotterid: $("#id").text(),
					cname: $("#cname").text(),
					cname1: $("#cname1").text(),
					period: Number($(".xiaqi").text()),
					lottermoney:$("#dzje").val(),		
					odds:odd
				},
				success: function(data) {
					var json = eval('(' + data + ')');
					var mess = json.message;
					if(json.state==1){
						if(mess=='0'){
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", json.data) 
							$("#checkboxhm").prop("checked", false)
							$("#checkboxgd").prop("checked", false)
							XIAZHU_BTN_LOCK = true
							return
						}
						if (json.data === 10) {
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络繁忙，请退出页面重试")
							$("#checkboxhm").prop("checked", false)
							$("#checkboxgd").prop("checked", false)
							XIAZHU_BTN_LOCK = true
							return
						}
							$("#balance").text("￥"+ new Number(json.message))
							//alertme("下注成功")
							var parentUl = document.querySelector(".ul-c-betSuccessItem")
							var wanfaHTML = ""
							for (var i = 1; i <= 40; i++) {
								var item = json.data["cplay" + i]
								if (item != null) {
									var value = "<td>" + json.data["cplay" + i] + "</td><td>" + json.data["str" + i] + "</td>"
									value = "<tr>" + value + "</tr>"
									wanfaHTML += value
								}
							}
							var shouyizhi = (Number(json.data.lottermoney) * Number(MONEY_FROM_SERVER)).toFixed(2)
							parentUl.innerHTML = "<tr><td>投注期号</td><td><span style='color:black;font-weight:bold;'>" + json.data.period + "</span></td></tr>" + 
							"<tr><td>投注注数</td><td><span style='color:red;font-weight:bold;'>" + COUNT_FROM_SERVER + " 注</span></td></tr>"+
							"<tr><td>投注金额</td><td><span style='color:red;font-weight:bold;'>" + ZONGZHUSHU + " 元</span></td></tr>"+
							"<tr><td>预估收益值</td><td><span style='color:red;font-weight:bold;'> " + shouyizhi + " 元</span></td></tr>"+
							"<tr class='wanfa-li-special'><td style='font-weight:bold;'>玩法</td><td style='font-weight:bold;'>投注号码</td></tr>"+ wanfaHTML
							var orderId = json.data.id;
							//拿开奖号
						 	$.ajax({
								url: "/findNextNextPeriod.do",
								type: "post",
								data: {
									"cname":$("#cname").text(),
									"type":1
								},
								success: function(data) {
									var fnextPeriod = data.data.nextperiod
									var nextPeriod = $(".xiaqi").text()//页面期号
									console.log($(".period").text(),data.data.period)
									if($(".period").text() == data.data.period){
										var haoma="";
										var lotterNumber =  data.data.lotternumber
										if(lotterNumber==null){
											lotterNumber = ""
										}
										lotterNumber1=lotterNumber.split(",");
										if(lotterNumber1.length > 1){
											$(".lotternumber").text(lotterNumber)
											 qiu()
										}else{
											$(".lotternumber").html("<span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>正</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>在</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>开</span><span style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;' class='text-center yuan qiu8'>奖</span>")
										}
									}
								}
							}) 
							if($("#checkboxhm").is(":checked")){
								var zcount=$(".fs").val();
								var price=$(".meifen").text();
								var profit=$(".tc").val();
								var rcount=$(".rg").val();
								var bcount=$(".bd").val();
								ajax({
									url:'/order/submit.do',
									type:'post',
									data:{
										id:orderId,
										zcount:zcount,
										price:price,
										rcount:rcount,
										bcount:bcount,
										state:0,
										hcount:0,	
									},
									success:function(data){
										var json = eval('(' + data + ')');
										if(json.message == "1"){
											$(".zdsd").addClass("hidden");
											clear1();
											$("#checkboxhm").removeAttr("checked");
											var html = ""
											var zongfenshuHTML = "<li>★总份数：<span style='color:red;font-weight:bold;'>" + zcount + " 份</span></li>"
											var rengoufenshuHTML = "<li>★认购份数：<span style='color:red;font-weight:bold;'>" + rcount + " 份</span></li>"
											var baodifenshuHTML = "<li>★保底份数：<span style='color:red;font-weight:bold;'>" + bcount + " 份</span></li>"
											html = zongfenshuHTML + rengoufenshuHTML + baodifenshuHTML
											$(".wanfa-li-special").before(html)
											$("#betSuccessModal .modal-title").text("发起合买成功!")
											$("#betSuccessModal").modal("show")
											setXianZhuZongE()
											XIAZHU_BTN_LOCK = true
										}
									},
									error: function() {
										XIAZHU_BTN_LOCK = true
									}
								});
							} 
							else if ($("#checkboxgd").is(":checked")) {
								var stateValue = testState == "1" ? "1" : "0"
								var allMoney = Number($("#zhushu").text()) * Number($("#dzje").val())
								var ajaxDataItem = {
										id:orderId,
										testState: stateValue,
										state: "0",
										odd: odd,
										rebate: rebate,
										payMoney: allMoney,
										gid: -1,
										moneys: 0,
									}
								if (stateValue == "1") {
									ajaxDataItem.shenglv = slv
								}
								ajax({
									url:'/order/payGendan.do',
									type:'post',
									data: ajaxDataItem,
									success:function(data){
										var newData = JSON.parse(data)
										$("#betSuccessModal .modal-title").text("跟单成功!")
										$("#betSuccessModal").modal("show")
										$("#checkboxgd").prop("checked", false)
										XIAZHU_BTN_LOCK = true
									},
									error: function() {
										XIAZHU_BTN_LOCK = true
									}
								});								
							}
							else {
								$("#betSuccessModal .modal-title").text("下注成功!")
								XIAZHU_BTN_LOCK = true
								$("#betSuccessModal").modal("show")
								setXianZhuZongE()
							}
							XIAZHU_BTN_LOCK = true
							clear1()
					}
				}
			}		
			setAllActItem(ajaxData.data)
			ajax(ajaxData);			
		}
		
		var XIAZHU_BTN_LOCK = true
		
		function comit() {
			if (!XIAZHU_BTN_LOCK) {
				return
			}
			XIAZHU_BTN_LOCK = false
			if ($("#checkboxhm").is(':checked') && $("#checkboxgd").is(':checked')) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "跟单与合买只能同时选中一个")
				$("#checkboxhm").prop('checked', false)
				$("#checkboxgd").prop('checked', false)
				XIAZHU_BTN_LOCK = true
				return
			}
			if (!checkValueIsNumber($("#dzje").val())) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "无效的单注金额")
				XIAZHU_BTN_LOCK = true
				return
			}
			if ($(".act").length === 0) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请先选择下注号码")
				XIAZHU_BTN_LOCK = true
				return				
			}
			if ($("#cname").text() != "xg6hc") {
				if (FAKE_ZHUSHU != 0){
					if ($("#checkboxgd").is(':checked'))  {
						ajax({
							url:'/order/getTestState.do',
							type:'post',
							data:{},
							success:function(data){
								var newData = JSON.parse(data)
								var dataArray = newData.message.split(",")
								confirmXiaZhu(dataArray[0], newData.data, dataArray[1])
								XIAZHU_BTN_LOCK = true
							}
						})
					} else {
						confirmXiaZhu()
					}				
				}
				else{
					showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请选择正确的号码")
					XIAZHU_BTN_LOCK = true
				}
			} else {
				ajax({
					url:'/lotter/xglhc.do',
					type:'post',
					data: {
						cname: "xg6hc",
						xg6hc: "",
						},
					success:function(data){
						var newData = JSON.parse(data)
						var lastObj = newData.data
						ajax({
							url: '/lotter/xglhc.do',
							type:'post',
							data: {
								cname: "xg6hc",
								xg6hc: lastObj.xg6hcstate + 1,
								},
							success:function(data){
								var newData = JSON.parse(data)
								var nextObj = newData.data
								var nowTime = transDateLetter(newData.message)
								var nextTime = transDateLetter(nextObj.nextStopOrderTimeEpoch)			
								var chazhiValue = Math.floor(new Date(nextTime).getTime() / 1000) - Math.floor(new Date(nowTime).getTime() / 1000)			
					 			// 一直没有派奖，现在正在开奖
								if (nextObj.touzhuzt === null && chazhiValue <= 0) {
									showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "已经封盘，无法进行下注操作")
									XIAZHU_BTN_LOCK = true
									return									
								}
								// 一直没有派奖，显示倒计时
								else if(nextObj.touzhuzt === null && chazhiValue <= 30) {
									showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "已经封盘，无法进行下注操作")
									XIAZHU_BTN_LOCK = true
									return									
								}
								// nextObj.touzhuzt != null, 直接显示
								else if (nextObj.touzhuzt != null) {
									showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "已经封盘，无法进行下注操作")
									XIAZHU_BTN_LOCK = true
									return
								}
							    if (FAKE_ZHUSHU != 0){
									if ($("#checkboxgd").is(':checked'))  {
										ajax({
											url:'/order/getTestState.do',
											type:'post',
											data:{},
											success:function(data){
												var newData = JSON.parse(data)
												var dataArray = newData.message.split(",")
												confirmXiaZhu(dataArray[0], newData.data, dataArray[1])
												XIAZHU_BTN_LOCK = true
											}
										})
									} else {
										confirmXiaZhu()
									}				
								}	
							},
							error: function(error) {
								showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络繁忙")
								XIAZHU_BTN_LOCK = true
							}							
						})							
					},
					error: function(error) {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络繁忙")
						XIAZHU_BTN_LOCK = true
					}					
				})				
			}
		}
		
		function help(url, str) {
			document.write("<form action=/help.do method=post name=form1 style='display:none'>");
			document.write("<input type=hidden name=url value='" + url + "'/>");
			document.write("<input type=hidden name=str value='" + str + "'/>");
			document.write("</form>");
			document.form1.submit();
		}
		$(function(){
			$(".user").click(function(){
				if($(".nav").attr("class").indexOf("hidden")!=-1){
					$(".nav").removeClass("hidden");
				}else{
					$(".nav").addClass("hidden");
				}
			});
			
			$(".wfbtn").click(function(){
				xz($("#id").text(),$("#cname").text(),$(this).attr("class").replace("wfbtn ",""))
			});
			$(".wf a").click(function(){
				$(".acti").removeClass("acti")
				$(this).addClass("acti")
			});
			$("#range,#danzhu").bind('input propertychange', function() {
				jisuan();
		    });
			
			$(".hemei .fs").blur(function() {
				var reg = /^[1-9]\d*$/;
				var heji1=$("#zhushu").text();
				var jieguo=heji1/Number($(".fs").val());
				if(!reg.test(Number($(".fs").val().trim()))){
					$(".fs").val("1");
				}else if(heji1/Number($(".fs").val())=="Infinity"){
					$(".fs").val("1");
				}else if(jieguo<1){
					$(".fs").val("1");
				}else{
					if(jieguo.toString().indexOf(".")!=-1&&jieguo.toString().split(".")[1].length>3){
						jieguo=jieguo.toString().split(".")[0]+"."+(Number(jieguo.toString().split(".")[1].substr(0,3))+1);
					}
					$(".meifen").text(jieguo*Number($("#dzje").val()));
					$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
					$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
				}
			});
			$(".hemei .rg").blur(function() {
				var reg = /^[1-9]\d*$/;
				if(!reg.test(Number($(".rg").val().trim()))){
					$(".rg").val("1");
				}else if((Number($(".rg").val()))>(Number($("#zhushu").text()))){
					$(".rg").val("1");
				}
				$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
			});
			$(".hemei .bd").blur(function() {
				var reg = /^[0-9]\d*$/;
				if(!reg.test(Number($(".bd").val().trim()))){
					$(".bd").val("0")
				}else if((Number($(".bd").val().trim())+Number($(".rg").val()))>Number($(".fs").val())){
					$(".bd").val("0")
				}
				$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
			});
			
			$("#checkboxhm").click(function(){
				if($(".zdsd").attr("class").indexOf("hidden")!=-1){
					if(Number($("#zhushu").text())!=0){
						$(".zdsd").removeClass("hidden");
						$("#checkboxgd").prop("checked", false)
					}else{
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请先选择号码，再选择合买")
						$("#checkboxhm").removeAttr("checked");
					}
				}else{
					$(".zdsd").addClass("hidden");
				}
			});
		});
 			var insertNewData = function(arr) {
				
				var div = document.querySelector(".modal-body")
				var currentCName = $("#cname").text()
				div.innerHTML = ""
				for (var i = 0; i < arr.length; i++) {
					var item = arr[i]
					var spanHTML = ""
					if (item.lotternumber.indexOf(",") === -1) {
						spanHTML = item.lotternumber
					} else {
						var spanArray = item.lotternumber.slice(0, item.lotternumber.length - 1)
						spanArray = spanArray.split(",")
						for (var j = 0; j < spanArray.length; j++) {
							var spanItem = spanArray[j]
							var specialClass = ""
							var xg6hcBackGround = ""
							if (SPECIAL_CAIZHONG.indexOf(currentCName) != -1) {
								specialClass = COLOR_OBJECT[j + 1]
							}
							if (currentCName === "xg6hc") {
								if (blueArr.indexOf(spanItem) != -1) {
									xg6hcBackGround = "style='background-color:#336DCC;'"
								}
								else if (greenArr.indexOf(spanItem) != -1) {
									xg6hcBackGround = "style='background-color:#09B832;'"
								}								
							}
							var html = "<span class='span-item-circle " + specialClass + "' " + xg6hcBackGround + ">" + spanItem + "</span>"
							if (j === spanArray.length - 1 && currentCName === "xg6hc") {
								html = "<span style='display:inline-flex;margin:1px;color:black;font-size:0.33rem;width:0.46rem;height:0.46rem;justify-content:center;align-items:center;max-width:26px;max-height:26px;'>+</span>" + html
							}
							if (j === spanArray.length - 1 && currentCName === "5f6hc") {
								html = "<span style='display:inline-flex;margin:1px;color:black;font-size:0.33rem;width:0.46rem;height:0.46rem;justify-content:center;align-items:center;max-width:26px;max-height:26px;'>+</span>" + html
							}
							spanHTML += html
						}
					}
					var html = "<div class='green'>"+
					"期号：<span>" + item.period + "</span><br>"+
					"奖号：" + spanHTML + "<br>"+
					"日期：<span>" + item.paijtime + "</span>"+
				"</div>"
					div.insertAdjacentHTML("beforeend", html)
				}
			} 
			
			document.querySelector("#a-i-lotterRecord").addEventListener(getEndClickEvent(), function(event) {
				window.location.href="/kaijiangjilu.do?cname="+$("#cname").text()
			})
var timerId = null 
var interval = null
		$("#dzje").focus(function(event) {
		var explorer = navigator.userAgent
		if(explorer.indexOf("UCBrowser") >= 0){
			var cnt = 0
			timerId = setInterval( function() {
			    if (cnt < 3) {
			      cnt++
			    } else {
			      clearInterval(timerId)
			      timerId = null
			      return
			    }
			   document.body.scrollTop = document.body.scrollHeight
		  }, 300)				
		}		
	})		
	$("#dzje").on("blur", function(event) {
	    if (timerId) {
		    clearInterval(timerId);
		    timerId = null;
		}
	    if (interval) {
			clearInterval(interval);
	    }
	})	
	$("#a-i-zoushitu").on(getEndClickEvent(), function() {
		var lotterName = "${lotter.cname }"
		if (lotterName == "gdkl10f" || lotterName == "cqkl10f") {
			alertme("快乐十分暂无走势图")
		} 
		else if (lotterName == "xg6hc") {
			alertme("香港六合彩暂无走势图")
		}
		else {
			location.href = "/zoushitu.do?caizhong=" + lotterName
		}
	})
	var setXianZhuZongE = function() {
	 	var urlPath = "/order/orderSum.do"
			var newRequest = {
				url: urlPath,
				type: "post",
				data: {
					period: $(".xiaqi").text(),
					cname: $("#cname").text(),
				},
				success: function(data) {
					var newData = JSON.parse(data)
					$("#span-i-xiazhuzonge").text(newData.data)
				},
				error: function(status) {
				}
			}
			ajax(newRequest)		
	}
	setXianZhuZongE()
	function autoUpDateXianShuZongE() {
		setInterval(function() {
			setXianZhuZongE()
		}, 1000)
	}
	
	$("#checkboxgd").on("change", function(event) {
		if ($(".act").length === 0 && event.currentTarget.checked) {
			showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "必须要选择号码后才可以选择跟单")
			$("#checkboxgd").prop("checked", false)
			return
		}
		if (event.target.checked) {
			$("#checkboxhm").prop("checked", false)
		}
	})
	
	
	autoUpdateUserBalance("#balance", "￥")
		$(".xiazhu").css("max-width", String($(".class-div-contentDiv").width() - 50) + "px")
	setTimeout(function() {
		$(".class-div-contentDiv").css("margin-top", "130px")
		jianrong()	
	qiu()
	checkHeMaiAndGenDanStatus()	
	bindControlQiuItem()
	setSlideData()
	}, 0)
	</script>
</html>
